home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / Harvest C / MPW Int & Lib / Interfaces / Connections.h < prev    next >
Text File  |  1991-04-17  |  7KB  |  265 lines

  1. /*
  2.     File:        Connections.h
  3.  
  4.     Contains:    C Interface to the Connection Manager
  5.  
  6.     Copyright:    © 1988-1990 by Apple Computer, Inc.
  7.                 All rights reserved.
  8.  
  9. */
  10.  
  11.  
  12. #ifndef    __CONNECTIONS__
  13. #define __CONNECTIONS__
  14.  
  15. #ifndef __DIALOGS__
  16. #include <Dialogs.h>
  17. #endif    __DIALOGS__
  18.  
  19. #ifndef __CTBUTILITIES__
  20. #include <CTBUtilities.h>
  21. #endif    __CTBUTILITIES__
  22.  
  23. /*    current Connection Manager version    */
  24. #define    curCMVersion         2
  25.  
  26. /*    current Connection Manager Environment Record version     */
  27. #define    curConnEnvRecVers    0
  28.     
  29. /* CMErr */
  30. typedef    OSErr CMErr;
  31.  
  32. #define cmGenericError         (-1)
  33. #define    cmNoErr                0
  34. #define cmRejected            1
  35. #define cmFailed            2
  36. #define cmTimeOut            3
  37. #define cmNotOpen            4
  38. #define cmNotClosed            5
  39. #define cmNoRequestPending    6
  40. #define cmNotSupported         7
  41. #define cmNoTools            8    
  42. #define    cmUserCancel        9
  43. #define    cmUnknownError        11
  44.  
  45. /* CMRecFlags and CMChannel        */
  46. /*        Low word of CMRecFlags is same as CMChannel    */
  47. typedef long CMRecFlags;
  48. typedef short CMChannel;
  49.  
  50. enum {
  51.      cmData             = 1 << 0,
  52.     cmCntl             = 1 << 1,
  53.     cmAttn             = 1 << 2,
  54.     
  55.     cmDataNoTimeout    = 1 << 4,
  56.     cmCntlNoTimeout = 1 << 5,
  57.     cmAttnNoTimeout = 1 << 6,
  58.  
  59.     cmDataClean     = 1 << 8,        
  60.     cmCntlClean        = 1 << 9,
  61.     cmAttnClean        = 1 << 10,
  62.  
  63. /*        Only for CMRecFlags (not CMChannel) in the rest of this enum    */
  64.     cmNoMenus         = 1 << 16,    
  65.     cmQuiet            = 1 << 17
  66. };
  67.  
  68. /*    connection status flags    */
  69. typedef long CMStatFlags;
  70.  
  71. enum {
  72.     cmStatusOpening        = 1 << 0,
  73.     cmStatusOpen         = 1 << 1,
  74.     cmStatusClosing     = 1 << 2,
  75.     cmStatusDataAvail     = 1 << 3,
  76.     cmStatusCntlAvail     = 1 << 4,
  77.     cmStatusAttnAvail     = 1 << 5,
  78.     
  79.     cmStatusDRPend         = 1 << 6,        /* data read pending    */
  80.     cmStatusDWPend         = 1 << 7,        /* data write pending    */
  81.     cmStatusCRPend         = 1 << 8,        /* cntl read pending    */
  82.     cmStatusCWPend         = 1 << 9,        /* cntl write pending    */
  83.     cmStatusARPend         = 1 << 10,        /* attn read pending    */
  84.     cmStatusAWPend         = 1 << 11,        /* attn write pending    */
  85.  
  86.     cmStatusBreakPend     = 1 << 12,
  87.     cmStatusListenPend     = 1 << 13,
  88.     cmStatusIncomingCallPresent 
  89.                         = 1 << 14,
  90.  
  91.     cmStatusReserved0    = 1 << 15
  92. };
  93.  
  94. /*    CMBuffers    fields    */
  95. typedef short CMBufFields;
  96.  
  97. enum {
  98.     cmDataIn,
  99.     cmDataOut,
  100.     
  101.     cmCntlIn,
  102.     cmCntlOut,
  103.     
  104.     cmAttnIn,
  105.     cmAttnOut,
  106.     
  107.     cmRsrvIn,
  108.     cmRsrvOut
  109. };
  110.  
  111. typedef Ptr CMBuffers[8];
  112. typedef long CMBufferSizes[8];
  113.  
  114. /*    CMSearchFlags    */
  115. typedef short CMSearchFlags;
  116.  
  117. enum {
  118.     cmSearchSevenBit =    1 << 0
  119. };
  120.  
  121. /*    CMFlags (CMRead/Write deliminator flags)    */
  122. typedef short CMFlags;
  123. enum {
  124.     cmFlagsEOM        =    1 << 0
  125. };
  126.  
  127. struct ConnEnvironRec {
  128.     short        version;
  129.     long        baudRate;
  130.     short        dataBits;
  131.     CMChannel    channels;
  132.     Boolean        swFlowControl;
  133.     Boolean        hwFlowControl;
  134.     CMFlags        flags;
  135. };
  136. typedef struct ConnEnvironRec ConnEnvironRec;
  137.  
  138. typedef ConnEnvironRec *ConnEnvironRecPtr;
  139.  
  140.  
  141. struct ConnRecord {
  142.     short        procID;
  143.     
  144.     CMRecFlags    flags;
  145.     CMErr        errCode;
  146.     
  147.     long        refCon;
  148.     long        userData;
  149.     
  150.     ProcPtr        defProc;
  151.     
  152.     Ptr            config;
  153.     Ptr            oldConfig;
  154.     
  155.     long        asyncEOM;
  156.     
  157.     long        reserved1;
  158.     long        reserved2;
  159.  
  160.     Ptr            cmPrivate;
  161.  
  162.     CMBuffers        bufferArray;
  163.     CMBufferSizes    bufSizes;
  164.  
  165.     long        mluField;
  166.     
  167.     CMBufferSizes    asyncCount;
  168. };
  169.  
  170. typedef struct ConnRecord ConnRecord;
  171. typedef ConnRecord *ConnPtr, **ConnHandle;
  172.  
  173.  
  174. #ifdef __cplusplus
  175. extern "C" {
  176. #endif    
  177. pascal CMErr        InitCM(void);
  178. pascal Handle     CMGetVersion(ConnHandle hConn);
  179. pascal short     CMGetCMVersion(void);
  180.  
  181. pascal ConnHandle    CMNew(short procID, CMRecFlags flags, const CMBufferSizes desiredSizes, 
  182.                                 long refCon, long userData);
  183.  
  184. pascal void         CMDispose(ConnHandle hConn);
  185.  
  186. pascal CMErr     CMListen(ConnHandle hConn, Boolean async, ProcPtr completor, long timeout);
  187. pascal CMErr     CMAccept(ConnHandle hConn, Boolean accept);
  188.  
  189. pascal CMErr     CMOpen(ConnHandle hConn, Boolean async, ProcPtr completor, long timeout);
  190. pascal CMErr     CMClose(ConnHandle hConn, Boolean async, ProcPtr completor, long timeout, Boolean now);
  191.  
  192. pascal CMErr     CMAbort(ConnHandle hConn);
  193.  
  194. pascal void         CMIdle(ConnHandle hConn);
  195. pascal CMErr     CMStatus(ConnHandle hConn, CMBufferSizes sizes, CMStatFlags *flags);
  196.  
  197. pascal void         CMReset(ConnHandle hConn);
  198.  
  199. pascal void         CMBreak(ConnHandle hConn, long duration, Boolean async, 
  200.                             ProcPtr completor);
  201.  
  202. pascal CMErr     CMRead(ConnHandle hConn, Ptr theBuffer, long *toRead, 
  203.                             CMChannel theChannel, Boolean async, ProcPtr completor, long timeout, 
  204.                             CMFlags *flags);
  205.  
  206. pascal CMErr     CMWrite(ConnHandle hConn, Ptr theBuffer, long *toWrite,
  207.                             CMChannel theChannel, Boolean async, ProcPtr completor, long timeout, 
  208.                             CMFlags flags);
  209.  
  210. pascal CMErr     CMIOKill(ConnHandle hConn, short which);
  211.  
  212. pascal void         CMActivate(ConnHandle hConn, Boolean activate);
  213. pascal void         CMResume(ConnHandle hConn, Boolean resume);
  214. pascal Boolean     CMMenu(ConnHandle hConn, short menuID, short item);
  215.  
  216. pascal Boolean     CMValidate(ConnHandle hConn);
  217. pascal void         CMDefault(Ptr *theConfig, short procID, Boolean allocate);
  218.  
  219. pascal Handle     CMSetupPreflight(short procID, long *magicCookie);
  220. pascal Boolean     CMSetupFilter(short procID, Ptr theConfig, short count, 
  221.                             DialogPtr theDialog, EventRecord *theEvent, short *theItem, 
  222.                             long *magicCookie);
  223. pascal void         CMSetupSetup(short procID, Ptr theConfig, short count, 
  224.                             DialogPtr theDialog, long *magicCookie);
  225. pascal void         CMSetupItem(short procID, Ptr theConfig, short count, 
  226.                             DialogPtr theDialog, short *theItem, long *magicCookie);
  227. pascal void         CMSetupCleanup(short procID, Ptr theConfig, short count, 
  228.                             DialogPtr theDialog, long *magicCookie);
  229. pascal void         CMSetupPostflight(short procID);
  230.  
  231. pascal Ptr         CMGetConfig(ConnHandle hConn);
  232. pascal short     CMSetConfig(ConnHandle hConn, Ptr thePtr);
  233.  
  234. pascal OSErr     CMIntlToEnglish(ConnHandle hConn, 
  235.                             Ptr inputPtr, Ptr *outputPtr, short language);
  236. pascal OSErr     CMEnglishToIntl(ConnHandle hConn, 
  237.                             Ptr inputPtr, Ptr *outputPtr, short language);
  238.  
  239. pascal long         CMAddSearch(ConnHandle hConn, const Str255 theString, 
  240.                             CMSearchFlags flags, ProcPtr callBack);
  241. pascal void        CMRemoveSearch(ConnHandle hConn, long refnum);
  242. pascal void        CMClearSearch(ConnHandle hConn);
  243.  
  244. pascal CMErr     CMGetConnEnvirons(ConnHandle hConn, ConnEnvironRec *theEnvirons);
  245.         
  246. pascal short     CMChoose(ConnHandle *hConn, Point where, ProcPtr idleProc);
  247.  
  248. pascal void        CMEvent(ConnHandle hConn, const EventRecord *theEvent);
  249.  
  250. pascal void         CMGetToolName(short procID, Str255 name);
  251. pascal short     CMGetProcID(const Str255 name);
  252.  
  253. pascal void        CMSetRefCon(ConnHandle hConn, long refCon);
  254. pascal long         CMGetRefCon(ConnHandle hConn);
  255.  
  256. pascal long         CMGetUserData(ConnHandle hConn);
  257. pascal void         CMSetUserData(ConnHandle hConn, long userData);
  258.  
  259.  
  260.  
  261. #ifdef __cplusplus
  262. }
  263. #endif
  264.  
  265. #endif __CONNECTIONS__